package com.yxy.mapper;

import com.github.pagehelper.Page;
import com.yxy.pojo.dto.RemarkPageQueryDTO;
import com.yxy.pojo.entity.Remark;
import com.yxy.pojo.vo.RemarkPageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RemarkMapper {
    /**
     * 添加评论
     * @param remark
     */
    void add(Remark remark);

    /**
     * 分页查询
     * @param remarkPageQueryDTO
     * @return
     */
    Page<RemarkPageQueryVO> pageQuery(RemarkPageQueryDTO remarkPageQueryDTO);

    /**
     * 删除评论
     * @param id
     */
    @Delete("delete from remark where id = #{id}")
    void deleteById(int id);

    /**
     * 根据id查询评论
     * @param remarkId
     * @return
     */
    @Select("select * from remark where id = #{remarkId}")
    Remark selectById(int remarkId);

    /**
     * 更新评论表中的点赞数
     * @param remark
     */
    void update(Remark remark);

    /**
     * 根据评论类型和评论id查询评论
     * @param id
     * @param route
     * @return
     */
    @Select("select * from remark where type = #{type} and type_id = #{typeId}")
    List<Remark> selectCountByTypeAndTypeId(int typeId, String type);
}
